function OrderItem(price, name){
	this.price = null;
	this.name = null;
	this.qty = null;
	this.ident = null;
	this.orderers = null;
	
	//constructor
	this.init = function(){
		this.price = 0.00;
		this.qty = 1;
		this.ident = new Date().getTime().toString();
		this.orderers = new Array();
	};
	this.setName = function(name){
		if (typeof name != 'undefined' && name != null ) {
			this.name = name;
		} else {
			this.name = '';
		}
	};
	
	this.setQty = function(qty){
		this.qty = qty;
	};
	
	this.setPrice = function(price){
		this.price = parseFloat(price);
	};
	
	this.setOrderer = function(Orderer){
		this.orderers.push(Orderer);
	};
	
	this.removeOrderer = function(ident){
		removeArrItem(this.orderers, ident);
	};
	
	this.getOrderer = function(ident){
		getArrItem(this.orderers, ident);
	};
	
	this.init();
}

function Orderer(){
	this.name = null;
	this.orderedItems = null;
	this.ident = null;
	
	this.init = function(){
		this.orderedItems = new Array();
		this.ident = new Date().getTime().toString();
	};
	
	this.setName = function(name){
		if (typeof name != 'undefined' && name != null ) {
			this.name = name;
		} else {
			this.name = '';
		}
	};
	
	this.addItem = function(OrderItem){
		this.orderedItems.push(OrderItem);
	};
	
	this.removeItem = function(OrderItemIdent){
		removeArrItem(this.orderedItems, OrderItemIdent);
	};
	
	this.init();
}

function Bill(){
	this.name = null;
	this.people = null;
	this.items = null;
	this.ident = null;
	
	this.init = function(){
		this.people = new Array();
		this.items = new Array();
		this.ident = new Date().getTime().toString();
	};
	
	this.addPerson = function(Orderer){
		this.people.push(Orderer);
	};
	
	this.removePerson = function(personIdent){
		removeArrItem(this.people, personIdent);
	};
	
	this.getPerson = function(personIdent){
		return getArrItem(this.people, personIdent);	
	};
	
	this.addItem = function(OrderItem){
		this.items.push(OrderItem);
	};
	
	this.removeItem = function(itemIdent){
		removeArrItem(this.items, itemIdent);
	};
	
	this.getItem = function(itemIdent){
		return getArrItem(this.items, itemIdent);
	};
	
	this.getTotalCost = function(){
		var totalCost = 0;
		for(var i=0;i<this.items.length;i++){
			var item = this.items[i];
			totalCost += item.price * item.qty;
		}
		
		return totalCost;
	};
	
	this.init();
}
var unix = Math.round(+new Date()/1000);



